#!/usr/bin/ruby
require "mysql"
# check the database information
begin
  email_init = "zhangxmbxy@hotmail.com"
  my = Mysql.new("db1.shermanstravel.com", "webuser", "0xQ!=_7R", 'st')
####
#  res = my.query("SELECT * FROM people where email = 'zhangxmbxy@hotmail.com' ")   
  res = my.query("SELECT * FROM people where email = '"+ email_init +"' ")   

	res.each do |row|    
	printf "First Name: %s, Last Name : %s\n", row[3], row[4]
	printf "\n"

  end
  
####
  res2 = my.query("SELECT postal_code FROM people p, people_addresses pa where p.email = '"+ email_init +"' and p.address_id = pa.id")
      if (!res2) 
        printf "error"
      end
  res2.each do |row|
  printf "the information has been stored successfully"
  printf "\n"
  printf "postal code: %s\n", row[0]
  end
end

